export function getShiftTime(){
    let nowDate = new Date()
    let nowHour = nowDate.getHours()
    let currShift
    let preShift
    if(nowHour < 8){
        currShift = {
            startTime : getYmd('-1')+ ' 20:00:00',
            endTime: getYmd()+ ' 08:00:00'
        }
        preShift = {
           startTime : getYmd('-1')+ ' 08:00:00',
           endTime: getYmd('-1')+ ' 20:00:00'
        }
    }else if(nowHour >= 8 && nowHour < 20){
        currShift = {
            startTime : getYmd()+ ' 08:00:00',
            endTime: getYmd()+ ' 20:00:00'
        }
        preShift = {
            startTime : getYmd('-1')+ ' 20:00:00',
            endTime: getYmd()+ ' 08:00:00'
        }
    }else if(nowHour >= 20){
        currShift ={
            startTime : getYmd()+ ' 20:00:00',
            endTime: getYmd('1')+ ' 08:00:00'
        }
        preShift = {
            startTime : getYmd()+ ' 08:00:00',
            endTime: getYmd()+ ' 20:00:00'
        }
    }
    return {currShift,preShift}
}

function getYmd(type){
    let timeNow = new Date()
    let sep = '-'
    if(type == '1'){
        // 明天
        timeNow.setDate(timeNow.getDate() + 1)
    }else if(type == '-1'){
        // 昨天的年月日
        timeNow.setDate(timeNow.getDate() - 1); // 设置天数 -1 天，昨天的日期
    }
    let y = timeNow.getFullYear();// 年
     var m = timeNow.getMonth() + 1;// 月
     m = m < 10 ? '0' + m : m;
     var d = timeNow.getDate();// 日
     d = d < 10 ? ('0' + d) : d;
     return  y + sep + m + sep + d;
}

